<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>华悦假日酒店 | 登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="icon" href="../../images/favicon.jpg" sizes="32x32">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/login.css" media="all">
</head>
<body>

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>华悦假日酒店</h2>
            <p>华悦假日酒店后台管理系统</p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username"
                       for="user_phone"></label>
                <input type="text" name="username" id="user_phone" lay-verify="required|number|phone"
                       placeholder="手机号码"
                       class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                       for="user_password"></label>
                <input type="password" name="password" id="user_password" lay-verify="required|pass"
                       placeholder="密码" autocomplete="off" class="layui-input">
                <div class="layui-form-mid layui-word-aux">请填写6到16位密码</div>
            </div>
            <div class="layui-form-item">
                <div id="user-login-slider"></div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;">
                <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                <a href="forget.html" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="user-login-submit">登 录</button>
            </div>
        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">
        <p>© 2020 <a href="/desk/welcome" target="_blank">huayue.com</a></p>
    </div>

</div>

<script src="../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user', 'sliderVerify', 'jquery', 'form'], function () {
        var $ = layui.$
            , setter = layui.setter
            , admin = layui.admin
            , form = layui.form
            , router = layui.router()
            , layer = layui.layer
            , search = router.search;

        var sliderVerify = layui.sliderVerify,
            form = layui.form;
        var slider = sliderVerify.render({
            elem: '#user-login-slider'
        });
        form.render();
        form.verify({pass: [/^[\S]{6,12}$/, '密码必须6到16位']});
        //提交
        form.on('submit(user-login-submit)', function (obj) {

            if (slider.isOk()) {//用于表单验证是否已经滑动成功
                var loginLoad = layer.msg('登录中', {
                    icon: 16
                    , shade: 0.01
                });
            } else {
                layer.msg("请先通过滑块验证");
                return false;
            }
            //请求登录接口
            admin.req({
                url: '/user/login' //实际使用请改成服务端真实接口
                , type: "post"
                , dataType: 'json'
                , data: {"phone": $("#user_phone").val(), "password": $("#user_password").val()}
                , done: function (res) {
                    layer.close(loginLoad);
                    //登入成功的提示与跳转
                    layer.msg(res.msg, {
                        icon: res.icon, time: 1200, end: function () {
                            if (res.status == 200) {
                                location.href = '../index.html'; //后台主页
                            }
                        }
                    });

                }
            });
        });
    });
</script>
</body>
</html>